<template>
	<view>
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 100rpx;" ></view>
		</view>
		<view class="mainpadding2 ffffff" v-else>
			<view class=" pdl" style="padding-top: 30rpx;" v-for="item in list.data" :key="item.id">
				<view class="flexbetween">
					<view class="xiaohuang titletext">購買{{item.num}}人{{item.day}}天</view>
					<view class="price">${{item.money}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="xiaohui smalltext ">{{http.timereturn(item.createtime * 1000)}}</view>
					<view class="xiaohui smalltext ">{{item.end_time_text}}到期</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				httpRequest.request('/api/shop/buyshopuserIndex', 'GET', {
					page: page || 1,
					limit: 12,
					shop_id:uni.getStorageSync("shop_id")
				}).then(res => {
					uni.stopPullDownRefresh()
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style>

</style>
